package cn.pop.hsp_system_v2.Service.impl;

import cn.pop.hsp_system_v2.Mapper.AppointMapper;
import cn.pop.hsp_system_v2.Mapper.SchedulingMapper;
import cn.pop.hsp_system_v2.Pojo.Doctor;
import cn.pop.hsp_system_v2.Pojo.Scheduling;
import cn.pop.hsp_system_v2.Service.SchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class SchedulingServiceImpl implements SchedulingService {
    @Autowired
    private SchedulingMapper schedulingMapper;
    @Autowired
    private AppointMapper appointMapper;

    @Override
    public HashMap<String,Object> SchedulingByDoc(Long Doc_Id){
        HashMap<String,Object> hashMap=new HashMap<String,Object>();
        Doctor doctor = appointMapper.selectDoctorById(Doc_Id);
        List<Scheduling> schedulings = schedulingMapper.selectSchedulingByDocId(Doc_Id);
        if(doctor.getId()!=null){
            hashMap.put("user",doctor);
            hashMap.put("SchedulingS",schedulings);
            hashMap.put("msg","请求成功");
            hashMap.put("code",200);
            return hashMap;
        }
        hashMap.put("msg","请求失败");
        hashMap.put("code",400);
        return hashMap;
    }

    @Override
    public Scheduling findSchedulingById(Integer id) {
        return schedulingMapper.findSchedulingById(id);
    }

}
